package action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import pojo.Book;
import service.BookManager;

import com.opensymphony.xwork2.ActionSupport;
@Controller
@ParentPackage(value="json-default")
public class BookAction extends ActionSupport{
	private Book b;
	@Autowired(required=true)
	private BookManager bm;
	public Book getB() {
		return b;
	}

	public void setB(Book b) {
		this.b = b;
	}

	@Action(value="addBook",results={@Result(name=ActionSupport.SUCCESS,type="json")})
	public String addBook(){
		bm.addBook(b);
		return SUCCESS;
	}

}
